3.252 \(\int (a+b \tan ^2(c+d x))^2 \, dx\)

Optimal. Leaf size=46 \[ \frac {b (2 a-b) \tan (c+d x)}{d}+x (a-b)^2+\frac {b^2 \tan ^3(c+d x)}{3 d} \]

[Out]

(a-b)^2*x+(2*a-b)*b*tan(d*x+c)/d+1/3*b^2*tan(d*x+c)^3/d

________________________________________________________________________________________

Rubi [A]  time = 0.03, antiderivative size = 46, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, integrand size = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.214, Rules used = {3661, 390, 203} \[ \frac {b (2 a-b) \tan (c+d x)}{d}+x (a-b)^2+\frac {b^2 \tan ^3(c+d x)}{3 d} \]

Antiderivative was successfully verified.

[In]

Int[(a + b*Tan[c + d*x]^2)^2,x]

[Out]

(a - b)^2*x + ((2*a - b)*b*Tan[c + d*x])/d + (b^2*Tan[c + d*x]^3)/(3*d)

Rule 203

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1*ArcTan[(Rt[b, 2]*x)/Rt[a, 2]])/(Rt[a, 2]*Rt[b, 2]), x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 390

Int[((a_) + (b_.)*(x_)^(n_))^(p_)*((c_) + (d_.)*(x_)^(n_))^(q_), x_Symbol] :> Int[PolynomialDivide[(a + b*x^n)
^p, (c + d*x^n)^(-q), x], x] /; FreeQ[{a, b, c, d}, x] && NeQ[b*c - a*d, 0] && IGtQ[n, 0] && IGtQ[p, 0] && ILt
Q[q, 0] && GeQ[p, -q]

Rule 3661

Int[((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_), x_Symbol] :> With[{ff = FreeFactors[Tan[e + f*x]
, x]}, Dist[(c*ff)/f, Subst[Int[(a + b*(ff*x)^n)^p/(c^2 + ff^2*x^2), x], x, (c*Tan[e + f*x])/ff], x]] /; FreeQ
[{a, b, c, e, f, n, p}, x] && (IntegersQ[n, p] || IGtQ[p, 0] || EqQ[n^2, 4] || EqQ[n^2, 16])

Rubi steps

\begin {align*} \int \left (a+b \tan ^2(c+d x)\right )^2 \, dx &=\frac {\operatorname {Subst}\left (\int \frac {\left (a+b x^2\right )^2}{1+x^2} \, dx,x,\tan (c+d x)\right )}{d}\\ &=\frac {\operatorname {Subst}\left (\int \left ((2 a-b) b+b^2 x^2+\frac {(a-b)^2}{1+x^2}\right ) \, dx,x,\tan (c+d x)\right )}{d}\\ &=\frac {(2 a-b) b \tan (c+d x)}{d}+\frac {b^2 \tan ^3(c+d x)}{3 d}+\frac {(a-b)^2 \operatorname {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (c+d x)\right )}{d}\\ &=(a-b)^2 x+\frac {(2 a-b) b \tan (c+d x)}{d}+\frac {b^2 \tan ^3(c+d x)}{3 d}\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.60, size = 73, normalized size = 1.59 \[ \frac {\tan (c+d x) \left (b \left (6 a-b \left (3-\tan ^2(c+d x)\right )\right )+\frac {3 (a-b)^2 \tanh ^{-1}\left (\sqrt {-\tan ^2(c+d x)}\right )}{\sqrt {-\tan ^2(c+d x)}}\right )}{3 d} \]

Antiderivative was successfully verified.

[In]

Integrate[(a + b*Tan[c + d*x]^2)^2,x]

[Out]

(Tan[c + d*x]*((3*(a - b)^2*ArcTanh[Sqrt[-Tan[c + d*x]^2]])/Sqrt[-Tan[c + d*x]^2] + b*(6*a - b*(3 - Tan[c + d*
x]^2))))/(3*d)

________________________________________________________________________________________

fricas [A]  time = 0.44, size = 51, normalized size = 1.11 \[ \frac {b^{2} \tan \left (d x + c\right )^{3} + 3 \, {\left (a^{2} - 2 \, a b + b^{2}\right )} d x + 3 \, {\left (2 \, a b - b^{2}\right )} \tan \left (d x + c\right )}{3 \, d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="fricas")

[Out]

1/3*(b^2*tan(d*x + c)^3 + 3*(a^2 - 2*a*b + b^2)*d*x + 3*(2*a*b - b^2)*tan(d*x + c))/d

________________________________________________________________________________________

giac [B]  time = 1.48, size = 359, normalized size = 7.80 \[ \frac {3 \, a^{2} d x \tan \left (d x\right )^{3} \tan \relax (c)^{3} - 6 \, a b d x \tan \left (d x\right )^{3} \tan \relax (c)^{3} + 3 \, b^{2} d x \tan \left (d x\right )^{3} \tan \relax (c)^{3} - 9 \, a^{2} d x \tan \left (d x\right )^{2} \tan \relax (c)^{2} + 18 \, a b d x \tan \left (d x\right )^{2} \tan \relax (c)^{2} - 9 \, b^{2} d x \tan \left (d x\right )^{2} \tan \relax (c)^{2} - 6 \, a b \tan \left (d x\right )^{3} \tan \relax (c)^{2} + 3 \, b^{2} \tan \left (d x\right )^{3} \tan \relax (c)^{2} - 6 \, a b \tan \left (d x\right )^{2} \tan \relax (c)^{3} + 3 \, b^{2} \tan \left (d x\right )^{2} \tan \relax (c)^{3} + 9 \, a^{2} d x \tan \left (d x\right ) \tan \relax (c) - 18 \, a b d x \tan \left (d x\right ) \tan \relax (c) + 9 \, b^{2} d x \tan \left (d x\right ) \tan \relax (c) - b^{2} \tan \left (d x\right )^{3} + 12 \, a b \tan \left (d x\right )^{2} \tan \relax (c) - 9 \, b^{2} \tan \left (d x\right )^{2} \tan \relax (c) + 12 \, a b \tan \left (d x\right ) \tan \relax (c)^{2} - 9 \, b^{2} \tan \left (d x\right ) \tan \relax (c)^{2} - b^{2} \tan \relax (c)^{3} - 3 \, a^{2} d x + 6 \, a b d x - 3 \, b^{2} d x - 6 \, a b \tan \left (d x\right ) + 3 \, b^{2} \tan \left (d x\right ) - 6 \, a b \tan \relax (c) + 3 \, b^{2} \tan \relax (c)}{3 \, {\left (d \tan \left (d x\right )^{3} \tan \relax (c)^{3} - 3 \, d \tan \left (d x\right )^{2} \tan \relax (c)^{2} + 3 \, d \tan \left (d x\right ) \tan \relax (c) - d\right )}} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="giac")

[Out]

1/3*(3*a^2*d*x*tan(d*x)^3*tan(c)^3 - 6*a*b*d*x*tan(d*x)^3*tan(c)^3 + 3*b^2*d*x*tan(d*x)^3*tan(c)^3 - 9*a^2*d*x
*tan(d*x)^2*tan(c)^2 + 18*a*b*d*x*tan(d*x)^2*tan(c)^2 - 9*b^2*d*x*tan(d*x)^2*tan(c)^2 - 6*a*b*tan(d*x)^3*tan(c
)^2 + 3*b^2*tan(d*x)^3*tan(c)^2 - 6*a*b*tan(d*x)^2*tan(c)^3 + 3*b^2*tan(d*x)^2*tan(c)^3 + 9*a^2*d*x*tan(d*x)*t
an(c) - 18*a*b*d*x*tan(d*x)*tan(c) + 9*b^2*d*x*tan(d*x)*tan(c) - b^2*tan(d*x)^3 + 12*a*b*tan(d*x)^2*tan(c) - 9
*b^2*tan(d*x)^2*tan(c) + 12*a*b*tan(d*x)*tan(c)^2 - 9*b^2*tan(d*x)*tan(c)^2 - b^2*tan(c)^3 - 3*a^2*d*x + 6*a*b
*d*x - 3*b^2*d*x - 6*a*b*tan(d*x) + 3*b^2*tan(d*x) - 6*a*b*tan(c) + 3*b^2*tan(c))/(d*tan(d*x)^3*tan(c)^3 - 3*d
*tan(d*x)^2*tan(c)^2 + 3*d*tan(d*x)*tan(c) - d)

________________________________________________________________________________________

maple [A]  time = 0.04, size = 87, normalized size = 1.89 \[ \frac {b^{2} \left (\tan ^{3}\left (d x +c \right )\right )}{3 d}+\frac {2 a b \tan \left (d x +c \right )}{d}-\frac {b^{2} \tan \left (d x +c \right )}{d}+\frac {\arctan \left (\tan \left (d x +c \right )\right ) a^{2}}{d}-\frac {2 \arctan \left (\tan \left (d x +c \right )\right ) a b}{d}+\frac {\arctan \left (\tan \left (d x +c \right )\right ) b^{2}}{d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a+b*tan(d*x+c)^2)^2,x)

[Out]

1/3*b^2*tan(d*x+c)^3/d+2*a*b*tan(d*x+c)/d-b^2*tan(d*x+c)/d+1/d*arctan(tan(d*x+c))*a^2-2/d*arctan(tan(d*x+c))*a
*b+1/d*arctan(tan(d*x+c))*b^2

________________________________________________________________________________________

maxima [A]  time = 1.13, size = 58, normalized size = 1.26 \[ a^{2} x - \frac {2 \, {\left (d x + c - \tan \left (d x + c\right )\right )} a b}{d} + \frac {{\left (\tan \left (d x + c\right )^{3} + 3 \, d x + 3 \, c - 3 \, \tan \left (d x + c\right )\right )} b^{2}}{3 \, d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)^2)^2,x, algorithm="maxima")

[Out]

a^2*x - 2*(d*x + c - tan(d*x + c))*a*b/d + 1/3*(tan(d*x + c)^3 + 3*d*x + 3*c - 3*tan(d*x + c))*b^2/d

________________________________________________________________________________________

mupad [B]  time = 11.42, size = 76, normalized size = 1.65 \[ \frac {\mathrm {tan}\left (c+d\,x\right )\,\left (2\,a\,b-b^2\right )}{d}+\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (c+d\,x\right )\,{\left (a-b\right )}^2}{a^2-2\,a\,b+b^2}\right )\,{\left (a-b\right )}^2}{d}+\frac {b^2\,{\mathrm {tan}\left (c+d\,x\right )}^3}{3\,d} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int((a + b*tan(c + d*x)^2)^2,x)

[Out]

(tan(c + d*x)*(2*a*b - b^2))/d + (atan((tan(c + d*x)*(a - b)^2)/(a^2 - 2*a*b + b^2))*(a - b)^2)/d + (b^2*tan(c
 + d*x)^3)/(3*d)

________________________________________________________________________________________

sympy [A]  time = 0.31, size = 68, normalized size = 1.48 \[ \begin {cases} a^{2} x - 2 a b x + \frac {2 a b \tan {\left (c + d x \right )}}{d} + b^{2} x + \frac {b^{2} \tan ^{3}{\left (c + d x \right )}}{3 d} - \frac {b^{2} \tan {\left (c + d x \right )}}{d} & \text {for}\: d \neq 0 \\x \left (a + b \tan ^{2}{\relax (c )}\right )^{2} & \text {otherwise} \end {cases} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate((a+b*tan(d*x+c)**2)**2,x)

[Out]

Piecewise((a**2*x - 2*a*b*x + 2*a*b*tan(c + d*x)/d + b**2*x + b**2*tan(c + d*x)**3/(3*d) - b**2*tan(c + d*x)/d
, Ne(d, 0)), (x*(a + b*tan(c)**2)**2, True))

________________________________________________________________________________________